﻿/* 
 * Since 2008 - 2012
 */

package com.hh.bss.project.service.impl;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.*;

import com.hh.bss.base.*;
import com.hh.bss.common.page.*;
import com.hh.bss.common.page.impl.*;
import com.hh.bss.project.dao.*;
import com.hh.bss.project.entity.*;
import com.hh.bss.project.service.*;
import com.hh.bss.project.vo.query.*;
import com.hh.bss.util.*;




@Service
@Transactional
public class ContractJobPartnerServiceImpl extends BaseBusinessService<ContractJobPartner,java.lang.Integer>  implements ContractJobPartnerService<ContractJobPartner,java.lang.Integer>{

	private ContractJobPartnerDao contractJobPartnerDao;
	private ContractJobService contractJobService;
	/**增加setXXXX()方法,spring就可以通过autowire自动设置对象属性,请注意大小写*/
	public void setContractJobPartnerDaoImpl(ContractJobPartnerDao dao) {
		this.contractJobPartnerDao = dao;
	}
	public void setContractJobServiceImpl(ContractJobService service) {
		this.contractJobService = service;
	}
	public EntityDao getEntityDao() {
		return this.contractJobPartnerDao;
	}
	
	@Transactional(readOnly=true)
	public Page findPage(ContractJobPartnerQuery query) {
		return contractJobPartnerDao.findPage(query);
	}
	public void save(ContractJobPartner entity){
		contractJobPartnerDao.save(entity);
		contractJobPartnerDao.flush();
    	contractJobService.updateJobPartner(entity.getJobId());
    	contractJobPartnerDao.flush();
	}
    public void update(ContractJobPartner entity){
    	contractJobPartnerDao.update(entity);
    	contractJobPartnerDao.flush();
    	contractJobService.updateJobPartner(entity.getJobId());
    	contractJobPartnerDao.flush();
	}
    public void removeById(Integer id){
    	//contractJobPartnerDao.delete(entity);
    	ContractJobPartner contractJobPartner=(ContractJobPartner)contractJobPartnerDao.getById(id);
    	contractJobPartnerDao.deleteById(id);
    	contractJobPartnerDao.flush();
    	if (contractJobPartner!=null)contractJobService.updateJobPartner(contractJobPartner.getJobId());
    	contractJobPartnerDao.flush();
    	
    }
	
	public boolean isExistMCRoleByJobId(Integer jobId) {
		// TODO Auto-generated method stub
		return contractJobPartnerDao.isExistMCRoleByJobId(jobId);
	}
	@Override
	public List getJobRoleListByJobId(Integer jobId, String role) {
		return contractJobPartnerDao.getJobRoleListByJobId(jobId, role);
	}
}
